package com.sckj.springboot.controller;

import com.sckj.springboot.entity.User;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/test")
public class TestController {

    //josn格式
    @RequestMapping("/user")
    public String getUser(){
        return "user";
    }

    @RequestMapping(value = "/get",method = RequestMethod.GET)
    public String testGet(){
        return "sucess";
    }

    @GetMapping("/user/{id}/{name}")
    public String testPathVaruable(@PathVariable(value = "id") Integer id,@PathVariable String name){
        System.out.println("获取到的id为：" +id);
        System.out.printf("获取的name为：" +name);
        return "success";
    }

    @GetMapping("/User")
    public String testRequestParam(@RequestParam Integer id){
        System.out.printf("获取到的id:" +id);
        return "success";
    }

    @PostMapping("/form1")
    public String testForm(@RequestParam String name ,@RequestParam String password){
        System.out.println("获取到的username为:" +name);
        System.out.println("获取到的password为:" +password);
        return "succes";
    }

    @PostMapping("/user")
    public String testRequestBody(@RequestBody User user){
        System.out.println("获取到的name为："+user.getUser());
        System.out.printf("获取到的password为：" +user.getUser());
        return "success";
    }
}

